package com.ftg.learn.chapter16;

/**
 * @author KangJx
 * @date 2021/7/26
 */
public class SingleTon {

    public static int c1;
    public static int c2 = 10;//=0
    public static int c3;
    private static SingleTon singleTon;

    private SingleTon() {
        c1++; //1
        c2++; //10
        c3++; //1
//       A: 0 -10 -0
//       B: 1 11 1
//       C:  1 10 1
    }


    public static SingleTon getInstance() {
        if(null == singleTon){
            return  new SingleTon();
        }
        return singleTon;
    }

    public int getCount2(){
        return c2;
    }

    public static void main(String[] args) {
        SingleTon singleTon = SingleTon.getInstance();
        System.out.println("c1=" + SingleTon.c1);
        System.out.println("c2=" + SingleTon.c2);
        System.out.println("c2=" + SingleTon.c3);
//        System.out.println("getcount2="+singleTon.getCount2());
    }
}

